package com.factory._13observe;

import com.factory._13observe.demo1.ConcreteObserver;
import com.factory._13observe.demo1.ConcreteSubject;
import com.factory._13observe.demo1.Observer;
import com.factory._13observe.demo1.Subject;
import com.factory._13observe.demo3.MObservable;
import com.factory._13observe.demo3.MObserver;

import java.util.concurrent.Flow;

/**
 * 观察者模式
 *
 * @author Qinye
 * @date 2023/8/13 15:50
 */
public class Test {
    public static void main(String[] args) {
        // demo1
        Subject subject = new ConcreteSubject();
        subject.attach(new ConcreteObserver());
        subject.notifyObservers();

        System.out.println("-----------------------------");

        // demo2

        com.factory._13observe.demo2.ConcreteSubject concreteSubject = new com.factory._13observe.demo2.ConcreteSubject();
        ConcreteObserver concreteObserver = new
                ConcreteObserver();
        concreteSubject.attach(concreteObserver);
        concreteSubject.change("new state....");

        System.out.println("-----------------------------");

      // demo jdk 9
        MObservable mObservable = new MObservable();
        mObservable.subscribe(new MObserver());

    }
}
